package com.smrs.goods.model;

import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;


public class GoodsAttributeModel extends GoodsBaseModel<Long>{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	

	
	
	private Set<GoodsCategoryModel> categories = new LinkedHashSet<GoodsCategoryModel>();
	
	private List<GoodsAttributeValueModel> attributeValues = new ArrayList<GoodsAttributeValueModel>();
	
	public List<GoodsAttributeValueModel> getAttributeValues() {
		return attributeValues;
	}

	public void setAttributeValues(List<GoodsAttributeValueModel> attributeValues) {
		this.attributeValues = attributeValues;
	}

	public Set<GoodsCategoryModel> getCategories() {
		return categories;
	}

	public void setCategories(Set<GoodsCategoryModel> categories) {
		this.categories = categories;
	}
	
	

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((code == null) ? 0 : code.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		
		GoodsAttributeModel other = (GoodsAttributeModel) obj;
		if (code == null && other.code != null) {			
				return false;
		}else if(id.equals(other.getId())){
				return true;			
		} else if (code!=null && !code.equals(other.code) ){
			return false;
		} else if(code!=null && !code.equals(other.code) && id!=null && !id.equals(other.getId())){
			return false;
		}else if(code!=null && code.equals(other.code) && id!=null && id.equals(other.getId()) && name!=null && name.equals(other.getName())){
			return true;
		} 		
		return false;
	}

	@Override
	public String toString() {
		return  "id="+id+ " name=" +name +" code=" + code   ;
	}
	
	
	
}
